/*
 * TagByteArray.h
 *
 *  Created on: 19 juin 2011
 *      Author: Pierrick Caillon <pierrick@megami.fr>
 */

#ifndef TAGBYTEARRAY_H_
#define TAGBYTEARRAY_H_

#include "NamedTag.h"
#include "IValueTag.h"
#include <sys/types.h>

namespace NamedBinaryTag
{

class __attribute__((visibility("default"))) TagByteArray: public NamedBinaryTag::NamedTag
{
private:
	size_t length;
	char *data;
public:
	TagByteArray();
	virtual ~TagByteArray();

	TagTypes get_TagType() const;

	void Read(std::istream &input, bool ignoreName);
	void Write(std::ostream &output, bool ignoreName) const;

	char* get_Value() const;
	void set_Value(char *value, size_t length);
    size_t get_Length() const;
    void set_Length(size_t length);
    char get_Item(size_t index) const throw();
    void set_Item(char value, size_t index) throw();

	ITag *clone() const;
protected:
	TagByteArray(void *root) : NamedTag(root) {}
	ITag *clone(void *newRoot) const;
};

}

#endif /* TAGBYTEARRAY_H_ */
